package com.nlp.visualization.utils;


import java.lang.reflect.Field;
import java.util.Date;
import java.util.List;
import java.util.Set;

public class Info {

  public static void print(String mes) {
    System.out.println(new Date() + "-----  " + mes + "  -----");
  }

  public static void printError(String mes) {
    System.err.println(new Date() + "-----  " + mes + "  -----");
  }

  // public static void print(List<String> strs) {
  // for (String str : strs) {
  // System.out.println(str);
  // }
  // }

  public static void printList(List<?> list) {
    for (int i = 0; i < list.size(); i++) {
      System.out.println(list.get(i).toString());
    }
  }

  public static String getStrList(List list) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < list.size(); i++) {
      sb.append((list.get(i).toString() + "\n"));
    }
    return sb.toString();
  }

  public static void printLists(List list) {
    for (int i = 0; i < list.size(); i++) {
      System.out.println(list.get(i).toString());
    }
  }

  public static void printStringMap(List<StringMap> strs) {
    for (StringMap strMap : strs) {
      System.out.println(strMap.key + " - " + strMap.value);
    }
  }

  public static void print(int mes) {
    System.out.println(new Date() + "-----  " + mes + "  -----");

  }

  public static void print(boolean mes) {
    System.out.println(new Date() + "-----  " + mes + "  -----");

  }

  public static void print(Set<?> set) {
    for (Object obj : set) {
      print(obj.toString());
    }
  }

  public static void printClassFieldValue(Object obj) {
    Field[] fields = obj.getClass().getDeclaredFields();

    try {
      for (Field field : fields) {
        String value = null;
        // 根据不同字段类型获得不同的类型值（？寻求更好方法）
        if (field.getType().getName().equals(String.class.getName())) {
          value = (String) field.get(obj);
        } else if (field.getType().getName().equals(Integer.class.getName()) || field.getType()
            .getName().equals("int")) {
          value = String.valueOf(field.getInt(obj));
        } else if (field.getType().getName().equals(Boolean.class.getName()) || field.getType()
            .getName().equals("boolean")) {
          value = String.valueOf(field.getBoolean(obj));
        } else {
          value = String.valueOf(field.get(obj));
        }
        print(field.getName() + "  " + value);
      }
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
  }

//  public static void printList(List<Menu> list, String space) {
//    for (int i = 0; i < list.size(); i++) {
//      Info.print(space + list.get(i).getName());
//    }
//  }

  public static void printPageBean(PageBean pageBean) {

  }

}
